<template>
    <div>
        <h2>Proxy代理</h2>
        <h2>firstName:{{firstName}}</h2>
        <h2>lastName:{{lastName}}</h2>
        <h2>计算属性:{{fullName}}</h2>
        <button @click="setValue">add</button>
    </div>
</template>

<script>
    import axios from "axios"
    export default {
        data(){
            return{
                firstName:"A",
                lastName: "B"
            }
        },
        created() {
            axios.get("http://127.0.0.1:3000/user").then((res)=>{
                console.log(res)
            })
        },
        computed:{
            fullName: {
                get(){
                    return this.firstName + "-" + this.lastName
                },
                set(newValue){//C-D
                    console.log("计算属性的set",newValue);//"C-D"
                    let fullName = newValue.split("-");//["C","D"]
                    this.firstName = fullName[0];
                    this.lastName = fullName[1];
                }
            }
        },
        methods:{
            setValue(){
                this.fullName = "C-D"
            }
        }

    };
</script>

<style lang="less" type="text/less" scoped>

</style>
